var pageParamStr = $.url().param('pageParam');
var bedCost = JSON.parse(pageParamStr);
initSubsidization();

var view = {
	data: bedCost
};

var vue_vm = new Vue({
	el: '#vue_vm',
	data: view
});

function initSubsidization() {
	if(bedCost.subsidization=='饭卡补助') {
		bedCost.subsidizationType = 1;
		bedCost.subsidizationMoney = bedCost.subsidizationValue;
		$("#hs1").attr("checked", "checked");
		$("#subsidizationMoney").val(bedCost.subsidizationMoney);
	}else if(bedCost.subsidization=='包餐补助') {
		bedCost.subsidizationType = 2;
		bedCost.subsidizationDay = bedCost.subsidizationValue;
		$("#hs2").attr("checked", "checked");
		$("#subsidizationDay").val(bedCost.subsidizationDay);
	}else {
		bedCost.subsidizationType = 3;
		$("#hs3").attr("checked", "checked");
	}
}

function save() {
	view.data.price = (view.data.price==''? 0: parseFloat(view.data.price));
	view.data.subsidizationValue = (view.data.subsidizationValue==''? 0: parseFloat(view.data.subsidizationValue));
	view.data.consDeductionWay = (view.data.consumptionType==1? (view.data.price/2).toFixed(2): view.data.price);
	view.data.discount = (view.data.discount==''? 0: parseFloat(view.data.discount));

	save_basic(path+'/bedCost/save', {bedCost:view.data}, function() {
		alert('保存成功');
	});
}